package demo1;

public class Test {
    void func2(int N){
        int count = 0;

        for (int i = 0; i < 2 * N; i++) {
            count++;
        }

        int m = 10;
        while(m-- > 0){
            count++;
        }
    }

    void func3(int N,int M){
        int count = 0;
        for (int i = 0; i < N; i++) {
            count++;
        }

        for (int i = 0; i < M; i++) {
            count++;
        }
    }

    void func4(){
        int count = 0;
        for (int i = 0; i < 100; i++) {
            count++;
        }
    }

    void bubbleSort(int[] array){
        boolean flag = true;
        for (int i = 0; flag && i < array.length - 1; i++) {
            flag = false;
            for (int j = i; j < array.length - i - 1; j++) {
                if(array[j] > array[j+1]){
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                    flag = true;
                }
            }
        }
    }

    int binarySearch(int[] array, int value) {
        int begin = 0;
        int end = array.length - 1;
        while(begin < end){
            int mid = (begin + end) / 2;
            if(array[mid] > value){
                end = mid - 1;
            }else if(array[mid] < value){
                begin = mid + 1;
            }else{
                return mid;
            }
        }

        return -1;
    }

    long factorial(int N) {
        return N < 2 ? N : factorial(N*(N-1));
    }

    int fibonacci(int N) {
        return N < 2? N : fibonacci(N - 1)+fibonacci(N-2);
    }

    public static void main1(String[] args) {
        int a = 10;
        Integer b = Integer.valueOf(a);//显示装箱
        Integer c = 10;//自动装箱
    }

    public static void main(String[] args) {
        Integer a = 10;
        int b = a;
        int c = a.intValue();
        double d = a.doubleValue();

        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
    }

}
